using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// از این کلاس برای ثبت سفارشات کالا از انبار استفاده می شود
/// </summary>
public class Class_tblOrder
{
    private String Str_UserName = String.Empty;
    private String Str_OrderDate = String.Empty;
    private Boolean Bln_ClosedBit = false;
    private Decimal Dec_OrderID = 0;

    public Class_tblOrder(String Str_UserName, String Str_OrderDate, Boolean Bln_ClosedBit)
	{
        this.Str_UserName = Str_UserName.Trim();
        this.Str_OrderDate = Str_OrderDate.Trim();
        this.Bln_ClosedBit = Bln_ClosedBit;
	}

    public Class_tblOrder(Decimal Dec_OrderID)
    {
        this.Dec_OrderID = Dec_OrderID;
    }

    public Decimal UDF_SaveOrder()
    {
        Decimal Dec_OrderID = 0;
        LSC_WareHouseDataContext db = new LSC_WareHouseDataContext();
        tblOrder tblOdr = new tblOrder();
        tblOdr.UserName = this.Str_UserName;
        tblOdr.OrderDate = Str_OrderDate;
        tblOdr.OrderClosedBit = Bln_ClosedBit;
        db.tblOrders.InsertOnSubmit(tblOdr);
        db.SubmitChanges();
        Dec_OrderID = tblOdr.OrderID;
        return Dec_OrderID;
    }

    public void UDF_CloseOrder()
    {
        LSC_WareHouseDataContext db = new LSC_WareHouseDataContext();
        try
        {
            tblOrder tblOdr = db.tblOrders.Single(n => n.OrderID == this.Dec_OrderID);
            tblOdr.OrderClosedBit = true;
            db.SubmitChanges();
        }
        catch
        {
 
        }

    }
}