public string UpdateData(string uid, data_POWaitingForApprove data, string username)
        {
            POWaitingForApproveDataContext db = new POWaitingForApproveDataContext();
            bool isAddNew = uid == "";

            string lichsu = "";

            POWaitingForApprove dt;

            if (isAddNew && true)
            {
                dt           = new POWaitingForApprove();
                dt.UID       = Guid.NewGuid();
                dt.CreatedBy = username;
                dt.CreatedOn = DateTime.Now;
                lichsu       = string.Format("{0:dd/MM/yyyy hh:mm:ss}: Create by {1}.\n", DateTime.Now, username);
                db.POWaitingForApproves.InsertOnSubmit(dt);
            }
            else
            {
                dt = db.POWaitingForApproves.SingleOrDefault(p => p.UID.ToString().Equals(uid));
                if (dt == null)
                {
                    return("Object cannot be found");
                }
                else
                {
                    lichsu = dt.ChangeLog;
                }
            }
            if (dt.Batch != data.Batch)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Batch: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Batch, data.Batch) + lichsu;
                dt.Batch = data.Batch;
            }
            if (dt.No != data.No)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change No: {2}->{3}.\n",
                                       DateTime.Now, username, dt.No, data.No) + lichsu;
                dt.No = data.No;
            }
            if (dt.Type != data.Type)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Type: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Type, data.Type) + lichsu;
                dt.Type = data.Type;
            }
            if (dt.Action_Message != data.Action_Message)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Action_Message: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Action_Message, data.Action_Message) + lichsu;
                dt.Action_Message = data.Action_Message;
            }
            if (dt.Accept_Action_Message != data.Accept_Action_Message)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Accept_Action_Message: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Accept_Action_Message, data.Accept_Action_Message) + lichsu;
                dt.Accept_Action_Message = data.Accept_Action_Message;
            }
            if (dt.Description != data.Description)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Description: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Description, data.Description) + lichsu;
                dt.Description = data.Description;
            }
            if (dt.Remark != data.Remark)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Remark: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Remark, data.Remark) + lichsu;
                dt.Remark = data.Remark;
            }
            if (dt.Location_Code != data.Location_Code)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Location_Code: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Location_Code, data.Location_Code) + lichsu;
                dt.Location_Code = data.Location_Code;
            }

            if (dt.Original_Quantity != data.Original_Quantity)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Original_Quantity: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Original_Quantity, data.Original_Quantity) + lichsu;
                dt.Original_Quantity = data.Original_Quantity;
            }
            if (dt.Quantity != data.Quantity)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Quantity: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Quantity, data.Quantity) + lichsu;
                dt.Quantity = data.Quantity;
            }
            if (dt.Unit_of_Measure_Code != data.Unit_of_Measure_Code)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Unit_of_Measure_Code: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Unit_of_Measure_Code, data.Unit_of_Measure_Code) + lichsu;
                dt.Unit_of_Measure_Code = data.Unit_of_Measure_Code;
            }
            if (dt.Direct_Unit_Cost != data.Direct_Unit_Cost)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Direct_Unit_Cost: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Direct_Unit_Cost, data.Direct_Unit_Cost) + lichsu;
                dt.Direct_Unit_Cost = data.Direct_Unit_Cost;
            }
            if (dt.Due_Date != data.Due_Date)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Due_Date: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Due_Date, data.Due_Date) + lichsu;
                dt.Due_Date = data.Due_Date;
            }
            if (dt.Vendor_No != data.Vendor_No)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Vendor_No: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Vendor_No, data.Vendor_No) + lichsu;
                dt.Vendor_No = data.Vendor_No;
            }
            if (dt.Vendor_Item_No != data.Vendor_Item_No)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Vendor_Item_No: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Vendor_Item_No, data.Vendor_Item_No) + lichsu;
                dt.Vendor_Item_No = data.Vendor_Item_No;
            }

            if (dt.Replenishment_System != data.Replenishment_System)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Replenishment_System: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Replenishment_System, data.Replenishment_System) + lichsu;
                dt.Replenishment_System = data.Replenishment_System;
            }
            if (dt.Status != data.Status)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Status: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Status, data.Status) + lichsu;
                dt.Status = data.Status;
            }
            //Insert/ Update khong insert du lieu comment.
            //if (dt.Comment != data.Comment)
            //{
            //    lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Comment: {2}->{3}.\n",
            //        DateTime.Now, username, dt.Comment, data.Comment) + lichsu;
            //    dt.Comment = data.Comment;
            //}
            if (dt.ConvertType != data.ConvertType)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change ConvertType: {2}->{3}.\n",
                                       DateTime.Now, username, dt.ConvertType, data.ConvertType) + lichsu;
                dt.ConvertType = data.ConvertType;
            }
            if (dt.Converted != data.Converted)
            {
                lichsu = String.Format("{0:dd/MM/yyyy hh:mm:ss}: {1} Change Converted: {2}->{3}.\n",
                                       DateTime.Now, username, dt.Converted, data.Converted) + lichsu;
                dt.Converted = data.Converted;
            }
            dt.UpdatedBy = username;
            dt.UpdatedOn = DateTime.Now;
            dt.ChangeLog = lichsu;
            db.SubmitChanges();
            return(dt.UID.ToString());
        }
Exemple #2
0
 public string UpdateData(string uid, data_POWaitingForApprove data, string username)
 {
     return(bll.UpdateData(uid, data, username));
 }