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 description for Class_tblProjectAssetDetail
/// </summary>
/// //از این کلاس برای درج اقلام مصرفی در هر پروژه استفاده می شود
public class Class_tblProjectAssetDetail
{
    private Decimal Dec_ProjectID = 0;
    private Decimal Dec_OrderDetailID = 0;
    private String Str_UserName = String.Empty;
    private String Str_UseCase = String.Empty;
    private String Str_Note = String.Empty;

    public Class_tblProjectAssetDetail(Decimal Dec_ProjectID, Decimal Dec_OrderDetailID, String Str_UserName, String Str_UseCase, String Str_Note)
    {
        this.Dec_ProjectID = Dec_ProjectID;
        this.Dec_OrderDetailID = Dec_OrderDetailID;
        this.Str_UserName = Str_UserName;
        this.Str_UseCase = Str_UseCase;
        this.Str_Note = Str_Note;
    }

    public void UDF_SaveProjectAssetDetail()
    {
        LSC_WareHouseDataContext db = new LSC_WareHouseDataContext();
        tblProjectAssetDetail tblPrjAsDetail = new tblProjectAssetDetail();
        Class_ShamsiTools Shamsi = new Class_ShamsiTools();
        Shamsi.UDF_GetCurrentShamsiDate();

        tblPrjAsDetail.ProjectID = Dec_ProjectID;
        tblPrjAsDetail.OrderdetailID = Dec_OrderDetailID;
        tblPrjAsDetail.DateTahvil = Shamsi.CurrentShmasiDate;
        tblPrjAsDetail.UserName = Str_UserName;
        tblPrjAsDetail.UseCase = Str_UseCase;
        tblPrjAsDetail.Note = Str_Note;

        db.tblProjectAssetDetails.InsertOnSubmit(tblPrjAsDetail);
        db.SubmitChanges();

        UDF_UpdateTahvilBit(Dec_OrderDetailID);
        
    }

    private void UDF_UpdateTahvilBit(Decimal Dec_OrderDetailID)
    {
        LSC_WareHouseDataContext db = new LSC_WareHouseDataContext();
        tblOrderDetail ordDtl = db.tblOrderDetails.Single(n => n.OrderDetailID == Dec_OrderDetailID);
        ordDtl.TahvilBit = Boolean.Parse("true");
        db.SubmitChanges();
    }

}
