public HttpResponseMessage Save(Entities.WareHousing.TransferIn ti)
 {
     if (ti.ID > 0)
     {
         return(Request.CreateResponse(HttpStatusCode.OK, ti.Update()));
     }
     else
     {
         return(Request.CreateResponse(HttpStatusCode.OK, ti.Save()));
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Retrieve single entry from the list
        /// </summary>
        /// <param name="Id">Id of that particular entry you want retrieve</param>
        /// <param name="LocationId">Location id of that particular entry</param>
        /// <returns>single transfer in details</returns>
        public static TransferIn GetDetails(int Id, int LocationId)
        {
            DBManager db = new DBManager();

            try
            {
                string query = @"select tr.Transfer_In_Id,isnull(tr.From_Location,0)[From_Location],isnull(tr.Entry_Date,0)[Entry_Date],
                               isnull(tr.Total_Tax_Amount,0)[Tot_Tax_Amount],isnull(tr.Total_Gross_Amount,0)[Tot_Gross_Amount],
                               isnull(tr.Total_Net_Amount,0)[Tot_Net_Amount],isnull(tr.Entry_No,0)[Entry_No],
                               isnull(tr.Status,0)[Status],td.Tid_Id,td.Tod_Id,td.item_id,td.Instance_Id,isnull(td.Quantity,0)[Quantity],isnull(td.Mrp,0)[Mrp],
                               isnull(td.Rate,0)[Rate],isnull(td.Selling_Price,0)[Selling_Price],isnull(td.Tax_Amount,0)[Tax_Amount],td.Tax_Id,
                               isnull(td.Gross_Amount,0)[Gross_Amount],
                               isnull(td.Status,0)[Status],td.Net_Amount,isnull(t.Percentage,0)[Tax_Percentage],l.Name[Location],isnull(i.Name,0)[Item],
                               isnull(i.Item_Code,0)[Item_Code],tr.Cost_Center_Id,j.Job_Id,cost.Fcc_Name[Cost_Center],j.Job_Name,
							   l.name[Location],l.Address1[Loc_Address1],l.Address2[Loc_Address2],l.Contact[Loc_Phone],l.Reg_Id1[Loc_RegId],tr.Terms_And_Conditions 
							   from TBL_TRANSFER_IN_REGISTER tr
                               left join TBL_TRANSFER_IN_DETAILS td on td.Transfer_In_Id=tr.Transfer_In_Id
                               left join TBL_TAX_MST t on t.Tax_Id=td.Tax_Id
                               left join TBL_LOCATION_MST l on l.Location_Id=tr.From_Location                              
                               left join tbl_item_mst i on i.item_Id=td.Item_Id
                               left join tbl_Fin_CostCenter cost on cost.Fcc_ID=tr.Cost_Center_Id
							   left join TBL_JOB_MST j on j.Job_Id=tr.Job_Id
                               where tr.From_Location=@Location_Id and tr.Transfer_In_Id=@Transfer_In_Id order by tr.Created_Date desc";
                db.CreateParameters(2);
                db.AddParameters(0, "@Location_Id", LocationId);
                db.AddParameters(1, "@Transfer_In_Id", Id);
                db.Open();
                DataTable dt = db.ExecuteQuery(CommandType.Text, query);
                if (dt != null)
                {
                    DataRow    row      = dt.Rows[0];
                    TransferIn register = new TransferIn();
                    register.ID                 = row["Transfer_In_Id"] != DBNull.Value ? Convert.ToInt32(row["Transfer_In_Id"]) : 0;
                    register.CostCenterId       = row["Cost_Center_Id"] != DBNull.Value ? Convert.ToInt32(row["Cost_Center_Id"]) : 0;
                    register.JobId              = row["Job_Id"] != DBNull.Value ? Convert.ToInt32(row["Job_Id"]) : 0;
                    register.FromLocation       = row["From_Location"] != DBNull.Value ? Convert.ToInt32(row["From_Location"]) : 0;
                    register.EntryDateString    = row["Entry_Date"] != DBNull.Value ? Convert.ToDateTime(row["Entry_Date"]).ToString("dd/MMM/yyyy") : string.Empty;
                    register.TaxAmount          = row["Tot_Tax_Amount"] != DBNull.Value ? Convert.ToDecimal(row["Tot_Tax_Amount"]) : 0;
                    register.Gross              = row["Tot_Gross_Amount"] != DBNull.Value ? Convert.ToDecimal(row["Tot_Gross_Amount"]) : 0;
                    register.NetAmount          = row["Tot_Net_Amount"] != DBNull.Value ? Convert.ToDecimal(row["Tot_Net_Amount"]) : 0;
                    register.EntryNo            = Convert.ToString(row["Entry_No"]);
                    register.Location           = Convert.ToString(row["Location"]);
                    register.LocationAddress1   = Convert.ToString(row["Loc_Address1"]);
                    register.LocationAddress2   = Convert.ToString(row["Loc_Address2"]);
                    register.LocationPhone      = Convert.ToString(row["Loc_Phone"]);
                    register.LocationRegId      = Convert.ToString(row["Loc_RegId"]);
                    register.TermsAndConditions = Convert.ToString(row["Terms_And_Conditions"]);
                    register.Status             = row["Status"] != DBNull.Value ? Convert.ToInt32(row["Status"]) : 0;

                    DataTable   inProducts = dt.AsEnumerable().Where(x => x.Field <int>("Transfer_In_Id") == register.ID).CopyToDataTable();
                    List <Item> products   = new List <Item>();
                    for (int j = 0; j < inProducts.Rows.Count; j++)
                    {
                        DataRow rowItem = inProducts.Rows[j];
                        Item    item    = new Item();
                        item.DetailsID     = rowItem["Tid_Id"] != DBNull.Value ? Convert.ToInt32(rowItem["Tid_Id"]) : 0;
                        item.InstanceId    = rowItem["instance_id"] != DBNull.Value ? Convert.ToInt32(rowItem["instance_id"]) : 0;
                        item.TodId         = rowItem["Tod_Id"] != DBNull.Value ? Convert.ToInt32(rowItem["Tod_Id"]) : 0;
                        item.ItemID        = rowItem["item_id"] != DBNull.Value ? Convert.ToInt32(rowItem["item_id"]) : 0;
                        item.Name          = rowItem["Item"].ToString();
                        item.MRP           = rowItem["Mrp"] != DBNull.Value ? Convert.ToDecimal(rowItem["Mrp"]) : 0;
                        item.CostPrice     = rowItem["Rate"] != DBNull.Value ? Convert.ToDecimal(rowItem["Rate"]) : 0;
                        item.SellingPrice  = rowItem["Selling_Price"] != DBNull.Value ? Convert.ToDecimal(rowItem["Selling_Price"]) : 0;
                        item.TaxPercentage = rowItem["Tax_Percentage"] != DBNull.Value ? Convert.ToDecimal(rowItem["Tax_Percentage"]) : 0;
                        item.Gross         = rowItem["Gross_Amount"] != DBNull.Value ? Convert.ToDecimal(rowItem["Gross_Amount"]) : 0;
                        item.NetAmount     = rowItem["Net_Amount"] != DBNull.Value ? Convert.ToDecimal(rowItem["Net_Amount"]) : 0;
                        item.TaxAmount     = rowItem["Tax_Amount"] != DBNull.Value ? Convert.ToDecimal(rowItem["Tax_Amount"]) : 0;
                        item.Quantity      = rowItem["Quantity"] != DBNull.Value ? Convert.ToDecimal(rowItem["Quantity"]) : 0;
                        item.ItemCode      = Convert.ToString(rowItem["Item_Code"]);
                        products.Add(item);
                        dt.Rows.RemoveAt(0);
                    }
                    register.Products = products;
                    return(register);
                }
                return(null);
            }
            catch (Exception ex)
            {
                Application.Helper.LogException(ex, "TransferIn |GetDetails(int Id,int LocationId)");
                return(null);
            }
        }